MODULE Vector
IMPLICIT NONE
CONTAINS

SUBROUTINE vectorSum(x1,y1,z1,x2,y2,z2)
REAL,INTENT(IN) :: x1,y1,z1,x2,y2,z2
PRINT *,'Sum :',x1+x2,y1+y2,z1+z2
END SUBROUTINE vectorSum

SUBROUTINE vectorDiff(x1,y1,z1,x2,y2,z2)
REAL,INTENT(IN) :: x1,y1,z1,x2,y2,z2
PRINT *,'Difference :',x1-x2,y1-y2,z1-z2
END SUBROUTINE vectorDiff

SUBROUTINE vectorDot(x1,y1,z1,x2,y2,z2)
REAL,INTENT(IN) :: x1,y1,z1,x2,y2,z2
PRINT *,'Dot product :',x1*x2 + y1*y2 + z1*z2
END SUBROUTINE vectorDot

SUBROUTINE vectorCross(x1,y1,z1,x2,y2,z2)
REAL,INTENT(IN) :: x1,y1,z1,x2,y2,z2
REAL :: x,y,z	!output vector
x=y1*z2 - y2*z1
y=x1*z2 - x2*z1
z=x1*y2 - x2*y1
PRINT *,'Cross product :',x,y,z
END SUBROUTINE vectorCross

END MODULE Vector



PROGRAM main
USE Vector
IMPLICIT NONE
REAL :: x1,y1,z1,x2,y2,z2
PRINT *,'Enter the first vector'
READ *,x1,y1,z1
PRINT *,'Enter the second vector'
READ *,x2,y2,z2
call vectorSum(x1,y1,z1,x2,y2,z2)
call vectorDiff(x1,y1,z1,x2,y2,z2)
call vectorDot(x1,y1,z1,x2,y2,z2)
call vectorCross(x1,y1,z1,x2,y2,z2)
END PROGRAM

